package com.wyk.demo.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.wyk.demo.entity.Emp;
import com.wyk.demo.service.EmpService;
import com.wyk.demo.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/emp")
@Api(tags = "员工接口类")
@CrossOrigin
public class EmpController {
    @Autowired
    private EmpService empService;

    @GetMapping("getAll/{currentPage}/{pageSize}")
    @ApiOperation(value = "分页查询员工信息")
    public Result<IPage<Emp>> getAll(@ApiParam(value = "当前页码",required = true) @PathVariable Integer currentPage,
                                     @ApiParam(value = "每页的个数",required = true) @PathVariable Integer pageSize){
        return empService.listByPage(currentPage,pageSize);
    }

    @ApiOperation(value = "删除单条信息")
    @DeleteMapping("delOne/{empno}")
    public Result delOne(@ApiParam(value = "员工的编号") @PathVariable Integer empno){
        return new Result(200,"员工删除成功",empService.removeById(empno));
    }
}
